package com.lc.sell.controller;

import com.lc.sell.util.UploadImageUtils;
import com.lc.sell.vo.ResultVo;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Api(tags = "图片上传控制器")
@Controller
public class FileController {


    @PostMapping(value = "fileUpload")
    @ResponseBody
    public ResultVo fileUpload(@RequestParam(value = "file") MultipartFile file) throws FileNotFoundException {
        String filename = UploadImageUtils.uploadImage(file);
        System.out.println(filename);
        Map<String,String> map = new HashMap<>();
        map.put("src",filename);
       return ResultVo.ok(0,"上传成功",map);
    }
}
